package com.example.common.rabbit.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author juzipi
 * @Date 2021/7/18 11:02
 * @Info
 */
@Service
public class RabbitService {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 发送String消息
     * @param exchange 交换机
     * @param routingKey 路由
     * @param message 消息
     * @return
     */
    public Boolean sendMessage(String exchange,String routingKey,Object message){
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }


    /**
     * 发送邮件
     * @param exchange 交换机
     * @param routingKey 路由
     * @param message 信息
     * @return
     */
    public Boolean sendEmail(String exchange,String routingKey,Object message){
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }


}
